package com.example.xm.presenter.home;

import com.example.xm.base.BasePresenter;
import com.example.xm.bean.HomeBean.HomeArticleChuanTongBean;
import com.example.xm.bean.HomeBean.HomeArticleDaShiJianBean;
import com.example.xm.bean.HomeBean.HomeArticleRenShiBean;
import com.example.xm.bean.HomeBean.HomeArticleYanJinBean;
import com.example.xm.common.CommonSubScriBer;
import com.example.xm.interfaces.home.IArticle;
import com.example.xm.model.HttpManager;
import com.example.xm.utiles.RxUtils;

public class ArticlePresenter extends BasePresenter<IArticle.ArticleView> implements IArticle.ArticlePresenter {
    @Override
    public void getRenShi() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getRenShi()
                .compose(RxUtils.<HomeArticleRenShiBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeArticleRenShiBean>(mView) {
                    @Override
                    public void onNext(HomeArticleRenShiBean HomeArticleRenShiBean) {
                        mView.getRenShiResult(HomeArticleRenShiBean);
                    }
                }));
    }

    @Override
    public void getChuanTong() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getChuanTong()
                .compose(RxUtils.<HomeArticleChuanTongBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeArticleChuanTongBean>(mView) {
                    @Override
                    public void onNext(HomeArticleChuanTongBean homeArticleChuanTongBean) {
                        mView.getChuanTongResult(homeArticleChuanTongBean);
                    }
                }));
    }

    @Override
    public void getYanJin() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getYanJin()
                .compose(RxUtils.<HomeArticleYanJinBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeArticleYanJinBean>(mView) {
                    @Override
                    public void onNext(HomeArticleYanJinBean homeArticleYanJinBean) {
                        mView.getYanJinResult(homeArticleYanJinBean);
                    }
                }));
    }

    @Override
    public void getDaShiJian() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getDaShiJian()
                .compose(RxUtils.<HomeArticleDaShiJianBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeArticleDaShiJianBean>(mView) {
                    @Override
                    public void onNext(HomeArticleDaShiJianBean homeArticleDaShiJianBean) {
                        mView.getDaShiJianResult(homeArticleDaShiJianBean);
                    }
                }));
    }
}
